package com.product.system.controller;

import com.bw.itext.pdf.service.PdfService;
import com.itextpdf.text.DocumentException;
import com.lowagie.text.BadElementException;
import com.product.system.PdfSignHelloWorld.C2_01_SignHelloWorld;
import com.product.system.domain.ArgpTradesmanRetailers;
import com.product.system.service.ArgpTradesmanRetailersService;
import com.product.system.utils.WaterMarkUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.List;

@RestController
public class PdfRetailersController {

    @Autowired
    private ArgpTradesmanRetailersService argpTradesmanRetailersService;

    @Autowired
    private PdfService pdfService;
    @Autowired
    private HttpServletResponse response;

    @RequestMapping("/pdf")
    public void pdf() throws Exception {
        List<ArgpTradesmanRetailers> list = argpTradesmanRetailersService.selectRetailersExcel();
        pdfService.export(list,"retailers.pdf","零售商信息", ArgpTradesmanRetailers.class);
        C2_01_SignHelloWorld.sign("D:\\pdf\\retailers.pdf","D:\\pdf\\retailers-sign.pdf");
        WaterMarkUtil.addWaterMark("D:\\pdf\\retailers-sign.pdf","D:\\pdf\\retailers-sign-water.pdf","测试水印",5);
        pdfService.download("D:\\pdf\\retailers-sign-water.pdf",response);
    }
}
